package com.example.springboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springboot.entity.Absent;
import com.example.springboot.entity.DormManager;
import com.example.springboot.entity.Student;
import com.example.springboot.mapper.AbsentMapper;
import com.example.springboot.mapper.DormBuildMapper;
import com.example.springboot.mapper.DormManagerMapper;
import com.example.springboot.mapper.StudentMapper;
import com.example.springboot.service.AbsentService;
import com.example.springboot.service.DormBuildService;
import com.example.springboot.service.DormManagerService;
import com.example.springboot.service.StudentService;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AbsentServiceImpl extends ServiceImpl<AbsentMapper, Absent> implements AbsentService {


    @Resource
    private AbsentMapper absentMapper;

    @Override
    public Page findbyname(String name,Integer pageNum, Integer pageSize, String search) {
        Page page = new Page<>(pageNum, pageSize);
        QueryWrapper<Absent> qw = new QueryWrapper<>();
        qw.like("name", name);
        Page absentPage = absentMapper.selectPage(page, qw);
        return absentPage;
    }
    //分页查询
    @Override
    public Page<Absent> find(Integer pageNum, Integer pageSize, String search) {
        Page page = new Page<>(pageNum, pageSize);
        QueryWrapper<Absent> qw = new QueryWrapper<>();
        qw.like("name", search);
        Page studentPage = absentMapper.selectPage(page, qw);
        return studentPage;
    }
    //添加缺寝记录
    @Override
    public int add(Absent absent) {
        int insert = absentMapper.insert(absent);
        return insert;
    }

    @Override
    public int deleteAbsent(Integer id) {
        int insert = absentMapper.deleteById(id);
        return insert;
    }
    /**
     * 更新学生缺寝记录信息
     */
    @Override
    public int updateAbsent(Absent absent) {
        int i = absentMapper.updateById(absent);
        return i;
    }



}
